<template>
  <div style="display:inline-block;width:100%">
    <div id="main2" style="width: 100%;height:400px;" />
  </div>
</template>

<script>
import * as echarts from 'echarts/core'
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent
} from 'echarts/components'
import { PieChart } from 'echarts/charts'
import { LabelLayout } from 'echarts/features'
import { CanvasRenderer } from 'echarts/renderers'

echarts.use([
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  PieChart,
  CanvasRenderer,
  LabelLayout
])
export default {
  mounted() {
    var chartDom = document.getElementById('main2')
    var myChart = echarts.init(chartDom)
    var option

    option = {
      title: {
        text: '房产数量比例',
        textStyle: {
          color: '#235894'
        }
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        top: '5%',
        left: 'center'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: '#fff',
            borderWidth: 2
          },
          label: {
            show: false,
            position: 'center'
          },
          emphasis: {
            label: {
              show: true,
              fontSize: '40',
              fontWeight: 'bold'
            }
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 1048, name: '公寓' },
            { value: 200, name: '别墅' },
            { value: 580, name: '商铺' }
          ]
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>

<style>

</style>
